package com.config;

import com.consts.Const;
import com.util.StringUtils;
import lombok.Data;

import java.util.HashMap;

/**
 * @author Smile
 */
@Data
public class Configuration {
    private int serviceMode;
    private String version;
    private String tyywAddress;
    private HashMap<String, String> tyywUri;

    private String csbAddress;
    private String csbAk;
    private String csbSk;
    private HashMap<String, String> csbUri;

    private boolean initCatalog;
    private String getEvidenceCatalog;

    private String clientPath;
    private Integer pageSize;
    private Integer threadSize;
    private String casePath;
    private String mediaPath;
    private String zipPath;

    private HashMap<String, Object> authorization;

    public String GetServiceInterface(Const cst) throws Exception {
        String serviceAddress = null;
        String serviceInterface = null;

        if (this.getServiceMode() == 1) {
            serviceAddress = this.getTyywAddress();
            serviceInterface = this.getTyywUri().get(cst);
        } else {
            serviceAddress = this.getCsbAddress();
            serviceInterface = this.getCsbUri().get(cst);
        }
        if (StringUtils.isEmpty(serviceAddress)) {
            throw new Exception("获取统一业务地址失败");
        }
        if (StringUtils.isEmpty(serviceInterface)) {
            throw new Exception("获取统一业务接口失败");
        }
        return serviceAddress + serviceInterface;
    }
}
